﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class admin_product_addProduct : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        addProduct();
    }

    private void addProduct()
    {
        DB db = new DB();
        db.addProduct(nameTextBox_cn.Text, nameTextBox_en.Text, descTextBox_cn.Text, descTextBox_en.Text, uploadFile(),recommendedProductCheckBox.Checked ? 1 : 0, newProductCheckBox.Checked ? 1 : 0, Convert.ToInt32(categoryList.SelectedValue));
    }

    private string uploadFile()
    {
        return Utils.uploadFile(imageFileUpload, Utils.getCurrentDirectory() + "\\pimages\\");
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //addProduct();
        clear();

    }
    private void clear()
    {
        Response.Redirect("addProduct.aspx");
    }
}
